home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
010
/
dui.arc
/
KEYBOARD.INC
< prev
Wrap
Text File
|
1986-12-28
|
2KB
|
65 lines
{
---- K E Y B O A R D ----
These routines will let you detect, and control, the various shift states of
the stardard PC keyboard (I don't know if they work on an AT, JR, or clone).
The function "KeyChk" will check the state of the specified key, and return
either TRUE of FALSE. The procedure "KeySet" will accept a key, and a state
(TRUE or FALSE), and will set the key to that state.
The key definitions are as follows:
LshDep - Is the left shift key depressed?
RshDep - Is the right shift key depressed?
CtlDep - Is the CTRL key depressed?
AltDep - Is the ALT key depressed?
ScrDep - Is ScrollLock depressed? ScrLok - Are we in ScrollLock state?
NumDep - Is NumLock depressed? NumLok - Are we in NumLock state?
CapDep - Is CapsLock depressed? CapLok - Are we in CapsLock state?
InsDep - Is Insert depressed? InsMod - Are we in Insert mode?
All states are checkable, but only the "___Lok" states can be meaningfully
set; I don't know what happens if you try to set a "___Dep" state (Norton
says it's "potentially very disruptive" to do so...)
--------- Examples ---------
Suppose we want to make the PC work like a standard typewriter, such that
if you press a SHIFT key, it turns off CapsLock. Just insert the following
code at some point where it will execute fairly often:
If (KeyChk(LshDep) or KeyChk(RshDep)) and KeyChk(CapLok)
Then KeySet(CapLok, False);
Or, suppose we just want to harass those people who leave the keyboard in
NUMLOCK state. How's this for user-hostile software:
If KeyChk(NumLok)
Then Sound(50+Random(800))
Else NoSound;
Makes it sound like you've got hornets in your hard disk!
-------------------------------------------------------------------------------
Public Domain, Mark VanTassel, 9/11/86
-------------------------------------------------------------------------------
}
Type K_Type=(RshDep, LshDep, CtlDep, AltDep, ScrLok ,NumLok ,CapLok, InsMod,
Kjunk1, Kjunk2, Kjunk3, Kjunk4, ScrDep, NumDep, CapDep, InsDep);
Var K_Bits:Set of K_Type Absolute $0000:$0417;
Procedure KeySet(Key:K_Type; TF:Boolean);
Begin
If TF
Then K_Bits := K_Bits + [Key]
Else K_Bits := K_Bits - [Key];
End;
Function KeyChk(Key:K_Type):Boolean;
Begin
KeyChk := Key in K_Bits;
End;